﻿using System;
using System.Threading.Tasks;

namespace FlexField.Metadata.TestHarness
{
    public class AlwaysBadValidator<TKey> : IEntityValidator<TKey>, IFieldValidator<TKey>
        where TKey : IEquatable<TKey>
    {
        public static readonly MetadataError ErrorMessage = new() { Description = "I'm Bad.", Code = "BadValidator" };
        
        public Task<MetadataResult> ValidateAsync(MetadataManager<TKey> manager, MetadataEntity<TKey> entity)
        {
            return Task.FromResult(MetadataResult.Failed(ErrorMessage));
        }

        public Task<MetadataResult> ValidateAsync(MetadataManager<TKey> manager, TKey typeId, MetadataField<TKey> field)
        {
            return Task.FromResult(MetadataResult.Failed(ErrorMessage));
        }
    }
}
